<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/default/easyui.css"/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/icon.css"/>" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>证书分类</title>
</head>
<body class="easyui-layout">
<script type="text/javascript">
		 var formatters = function(value,row,index){
			var edit = "<a butn='tb_btn_edit' onclick='editrow("+row.certypeId+","+row.certypeName+","+row.minDemand+","+row.hasSeveral+","+row.certypeRemark+")'></a>";
			var del = "<a butn='tb_btn_del' onclick='delrow("+row.certypeId+")'></a>";
			return edit+del;
		}
		//编辑
		 var editrow =function(certypeId,certypeName,minDemand,hasSeveral,certypeRemark){
			 var vv=$('#cf-certificateclassify-tb').datagrid('getSelected');
					console.log(vv.certypeName+"   ");
				$("#cf-certificateclassify-win").dialog("open"); 
				/*  parent.$('.dialog-button a:eq(0)').hide();
				parent.$('.dialog-button a:eq(1)').show(); */
				/*parent.$('.dialog-button a:eq(2)').show(); */
				$('#cf-zsfl-1').hide();
				$('#cf-zsfl-2').show();
				//$("#cf-trainactivity-kssj").textbox('setValue',trainingStarttime);
				$("#cf-certificateclassify-name").textbox('setValue',certypeName);
				$("#cf-certificateclassify-xql").textbox('setValue',minDemand);
				$("#cf-certificateclassify-yys").textbox('setValue',hasSeveral);
				$("#cf-certificateclassify-bz").textbox('setValue',certypeRemark);
				
		}
		 var edit = function(){
			$("<form method='get'>").appendTo(document.body).form({
				url:'certificateclassify_update',
				onSubmit:function(param){
					var vv=$('#cf-certificateclassify-tb').datagrid('getSelected');
					//alert(vv.certypeId);
					param['certypeId'] =vv.certypeId;
					param['certypeName'] = $("#cf-certificateclassify-name").textbox('getValue');
					param['zszlId'] =$("#cf-certificateclassify-cc").textbox('getValue');//vv.trainingStarttime;
					param['minDemand'] =$("#cf-certificateclassify-xql").textbox('getValue');//vv.trainingEndtime;
					param['hasSeveral'] =$("#cf-certificateclassify-yys").textbox('getValue');
					param['certypeRemark'] =$("#cf-certificateclassify-bz").textbox('getValue');
					
				},
				success:function(){
					$('#cf-certificateclassify-tb').datagrid('reload');
					$('#cf-certificateclassify-win').dialog('close');
				}
			}).submit().appendTo(".abc");	
		}
		 //删除
		var delrow= function(certypeId){
			$.messager.confirm('提示','确定删除该项',function(v){
				if(v){
					$.post('certificateclassify_remove',{certypeId:certypeId},function(){
						$('#cf-certificateclassify-tb').datagrid('reload');
					});
				}
			});
		} 
			$(function(){
				$("#cf-certificateclassify-tb").datagrid({onLoadSuccess: function(){
					$("a[butn=tb_btn_edit]").linkbutton({iconCls:'icon-edit', plain:true});
					$("a[butn=tb_btn_del]").linkbutton({iconCls:'icon-cancel', plain:true});
				}});
				$("#cf-certificateclassify-refresh").linkbutton({
					onClick : function() {
						$('#cf-certificateclassify-tb').datagrid('reload');
					}
				}); 
				//打开新增界面
				{
				 $("#cf-certificateclassify-add").linkbutton({
						onClick : function() {
							$("#cf-certificateclassify-win").dialog("open");
							$("#cf-certificateclassify-f").form('clear');
							/*  parent.$('.dialog-button a:eq(0)').show();
							parent.$('.dialog-button a:eq(1)').hide(); */
							$('#cf-zsfl-1').show();
							$('#cf-zsfl-2').hide();
						}
					}); 
				}
			});
	</script>
	<div class="abc"></div>
	<div id="cf-certificateclassify-tbs">
   		 <a id="cf-certificateclassify-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true,text:'新增',iconAlign:'left'"></a>
    	 <a id="cf-certificateclassify-refresh" class="easyui-linkbutton" data-options="iconCls:'icon-reload',text:'刷新',plain:true,iconAlign:'right'"></a>
    	 <input class="easyui-searchbox" data-options="label:'搜索',width:300,labelWidth:50,prompt:'分类名称',
     	searcher:function(value,name){
	         $('#cf-certificateclassify-tb').datagrid('load','certificateclassify_pages?certypeName='+value);
     	 }">
  </div>
		<table style="float:left" id="cf-certificateclassify-tb" class="easyui-datagrid" data-options="width:200,height:300,
			url:'certificateclassify_pages?certypeName=',
			fitColumns:true,
			fit:true,
			nowrap:false,
			loading:true,
			pagination:true,
			rownumbers:true,
			singleSelect:true,
			pageSize:10,
    		pageList:[10,20,30,40,50],
			toolbar:'#cf-certificateclassify-tbs',
			striped:true,
			method:'get'	
	">
		<thead>
		  <tr>
			<th data-options="field:'certypeId',width:150,align:'center'">分类编号</th>
			<th data-options="field:'certypeName',width:150,align:'center'">分类名称</th>
			<th data-options="field:'zszlId',width:100,align:'center'">证书种类编号</th>
			<th data-options="field:'zszlName',width:150,align:'center'">证书种类名称</th>
			<th data-options="field:'minDemand',width:90,align:'center'">最小需求量</th>
			<th data-options="field:'hasSeveral',width:60,align:'center'">拥有数</th>
			<th data-options="field:'certypeRemark',width:350,align:'center'">备注</th>
			<th data-options="field:'9',width:130,align:'center',formatter:formatters">操作</th>
		  </tr>	
		</thead>
		<tbody>
			 
		</tbody>
	</table>
	 <div id="cf-certificateclassify-win" class="easyui-dialog"data-options="width:400, height:370,
			title:'培训活动',
     		bodyCls:'certificateclassify_add',
      		modal:true,
      		closed:true,
      		buttons:[{
        	text:'确定',
			id:'cf-zsfl-1',
        	iconCls:'icon-save',
	        	handler:function(){
					$('#cf-certificateclassify-f').form({
					onSubmit:function(param){
						      //验证表单
						return $(this).form('validate');
					},
					success:function(v){
						//$.messager.alert('提示','注册成功');
						$('#cf-certificateclassify-win').dialog('close');
						$('#cf-certificateclassify-tb').datagrid('reload');
					}
				}).submit(); 
				}
			},{
        	text:'确定',
			id:'cf-zsfl-2',
        	iconCls:'icon-save',
	        	handler:edit
			},{
        	text:'取消',
        	iconCls:'icon-cancel',
	        	handler:function(){
	          		$('#cf-certificateclassify-win').dialog('close');
	        	}
			}
			]">
		 <form id="cf-certificateclassify-f" action="certificateclassify_add" method="get">
				<div class="line"style="margin-top:10px">
					        <input id="cf-certificateclassify-name" class="easyui-textbox" name="certypeName"
						data-options="label:'分类名称',width:250">
				</div>
				<div class="line"style="margin-top:10px">
						<!-- 	        <input id="cf-certificateclassify-sid" class="easyui-textbox" name="zszlId"
								data-options="label:'证书种类编号',width:120,required:true">
						<a id="cf-certificateclassify-add" class="easyui-linkbutton" data-options="iconCls:'icon-man',
						plain:true
						"></a>	 
								<input id="cf-certificateclassify-sname" class="easyui-textbox" name="zszlName"
								data-options="width:70,readonly:true,required:true"> -->
						证书种类编号<select id="cf-certificateclassify-cc" class="easyui-combogrid" name="zszlName" style="width:230px;margin-left:50px"   
					        data-options="    
					        	editable:false,
					            panelWidth:'auto',
					            panelHeight:'auto',    
					            value:'zszlName',    
					            idField:'zszlId',    
					            textField:'zszlName',    
					            url:'certificate_query1', 
					            method:'get', 
					            required:true,  
					            columns:[[    
					                {field:'zszlId',title:'证书种类编号',width:114},    
					                {field:'zszlName',title:'证书种类名称',width:114},    
					            ]]    
					        "></select>  		
				</div>
				<div class="line"style="margin-top:10px">
					        <input id="cf-certificateclassify-xql" class="easyui-textbox" name="minDemand"
						data-options="label:'最小需求量',width:250">
				</div>
				<div class="line"style="margin-top:10px">
					        <input id="cf-certificateclassify-yys" class="easyui-textbox" name="hasSeveral"
						data-options="label:'拥有数',width:250">
				</div>
				<div class="line"style="margin-top:10px">
					        <input id="cf-certificateclassify-bz" class="easyui-textbox" name="certypeRemark"
						data-options="label:'备注',multiline:true,width:250,height:70">
				</div>
		</form>
	</div>

</body>
</html>